<template>
  <div class="pic-title" :style="themStyle">
    <ul ref="$ulDom">
      <li v-for="(item, index) in showList" :key="index">
        <div class="pic">
          <a :href="`${newsBasePath}${item.link}`" target="_blank">
            <ShowImg :item="item" />
          </a>
        </div>
        <div class="info-pane">
          <div class="title">
            <!--标记-->
            <template v-if="item.extText">
              <template v-for="(ext, i) in item.extText">
                <Tag :key="i" :value="ext[0]" />
              </template>
            </template>
            <a :href="`${newsBasePath}${item.link}`" target="_blank">{{ item.subject }}</a>
          </div>
          <div class="info">
            <span>{{ item.createDate }}</span>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
  import Tag from './tag.vue';

  export default {
    name: 'PicTitle',
    components: {
      Tag
    },
    props: {
      list: { type: Array },
      options: { type: Object },
      contentWidth: { type: Number, default: 0 }
    },
    data() {
      return {
        imgBasePath: imgBasePath,
        newsBasePath: `${_basePath}/`
      };
    },
    computed: {
      showList() {
        return this.list ? this.list.slice(0, +this.options.count) : [];
      },
      themStyle() {
        return {
          // height: this.options.height + 'px',
          background: this.options.backgroundColor
          // width: this.contentWidth - 30 + 'px',
        };
      }
    },
    methods: {
      textOverflow(str) {
        return str.length > 30 ? `${str.substring(0, 30)}...` : str;
      }
    }
  };
</script>
<style lang="scss" scoped>
  .pic-title {
    // background-color: #000;
    padding: 0 10px;

    > ul {
      padding: 0;
      margin: 0;
      list-style: none;

      > li {
        height: 70px;
        // margin-bottom: 20px;
        padding: 10px 0;

        > div {
          // display: inline-block;
          vertical-align: top;
        }

        > .pic {
          float: left;

          > a {
            display: block;
            width: 120px;
            height: 70px;

            > img {
              width: 100%;
              height: 100%;
              border-radius: 4px;
            }
          }
        }

        > .info-pane {
          position: relative;
          height: 100%;
          margin-left: 130px;
          border-bottom: 1px solid #fff;

          > .title {
            display: block;
            width: 100%;
            overflow: hidden;
            font-size: 14px;
            font-weight: bold;
            color: #333;
            text-overflow: ellipsis;
            word-break: keep-all;
            white-space: nowrap;

            > div {
              display: inline-block;
            }
          }

          > .detail {
            margin-top: 10px;
            font-size: 12px;
            color: #999;
          }

          > .info {
            position: absolute;
            bottom: 0;
            padding: 10px 0;
            font-size: 12px;
            color: #999;

            > span {
              margin-right: 20px;
            }
          }
        }
      }
    }
  }
</style>
